home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / visual / perl.exe / {app} / MapIP.pl < prev    next >
Encoding:
Text File  |  2003-01-11  |  419 b   |  19 lines

  1. exit if (not defined($ARGV[1]));
  2. $hosts = $ARGV[1];
  3.  
  4. open(HOSTS,"$hosts");
  5. @lines = <HOSTS>;
  6. close HOSTS;
  7.  
  8. foreach (@lines) {
  9.  exit if ((~/^([\d\.]+)\s+(\S+)/) and ($2 eq $ARGV[0]));
  10.  # lines look like 
  11.  # 127.0.0.1       www.mysite.com 
  12.  
  13.  #If the line is already defined, exit so it doesn't get 
  14.  #added a second time.
  15. }
  16.  
  17. open(HOSTS,">>$hosts");
  18. print HOSTS "127.0.0.1       $ARGV[0]\n";
  19. close HOSTS;